#include "startwindow.h"

StartWindow::StartWindow(QWidget *parent)
    : QMainWindow{parent}
{
    startMainWidget = new QWidget(this);
    this -> setCentralWidget(startMainWidget);
    this -> setWindowTitle("围五开始界面");
    this -> setWindowFlag(Qt::FramelessWindowHint);
    this -> showFullScreen();

    QPalette palette(QPalette::Window,QColorConstants::Svg::lightblue);
    this -> setPalette(palette);

    startTitle = new QLabel("围   五");
    startTitle -> setStyleSheet("font:100px;color:blue;padding:5px;font-family:Arial;font-style:italic;border-radius:5px;text-align:center");

    aw = new AdjustWindow;

    vLayout = new QVBoxLayout(startMainWidget);
    vLayout -> setSpacing(30);
    vLayout -> setAlignment(Qt::AlignCenter );

    vLayout -> addWidget(startTitle);

    startButton = new QPushButton("START GAME",this);
    endButton = new QPushButton("END GAME",this);
    startButton -> setFixedSize(300,150);
    endButton -> setFixedSize(300,150);
    startButton -> setStyleSheet("color:white;"
                               "background-color:lightblue;"
                               "font-size:30px;"
                               "padding:3px 6px;"
                               "border-radius:5px;");
    endButton -> setStyleSheet("color:white;"
                             "background-color:lightblue;"
                             "padding:3px 6px;"
                             "font-size:30px;"
                             "border-radius:5px;");

    startButton -> setCursor(Qt::PointingHandCursor);
    endButton -> setCursor(Qt::PointingHandCursor);

    vLayout -> addWidget(startButton);
    vLayout -> addWidget(endButton);

    connect(endButton,&QPushButton::clicked,this,&StartWindow::onEndButtonClicked);
    connect(startButton,&QPushButton::clicked,this,&StartWindow::onStartButtonClicked);
    connect(aw,&AdjustWindow::signalCloseFromAdjust,this,&StartWindow::onEndButtonClicked);
}
StartWindow::~StartWindow(){
    delete startButton;
    delete endButton;
    delete vLayout;
    delete startMainWidget;
    delete aw;
}
void StartWindow::onEndButtonClicked(){
    this -> close();
}
void StartWindow::onStartButtonClicked(){
    this -> hide();
    aw->show();
}
